import request from "@/utils/request";

export const apiGetCourseList = (params) => {
  return request.post("/course/list", params);
};


export const apiGetCourseCategoryList = (parentId) => {
  return request.get("/course/category/loadTreeData?pid=" + parentId);
};

/**
 * 优选课程列表
 * @param params
 */
export const apiOptimalSelectList = (params) => {
  return request.post(`/course/optimalSelectList`, params);
};


/**
 * 推荐课程列表
 * @param params
 */
export const apiGetRecommendList = (params) => {
  return request.post(`/course/recommendList`, params);
};


//获取课程学习明细
export const apiGetCourseStudyDetail = (courseId) => {
  return request.get("/course/getCourseStudyDetail?id=" + courseId);
};

//计算任务学习时长
export const apiCalcStudyTime = (params) => {
  return request.post("/course/calcStudyTime", params);
};

//获取课程任务学习进度
export const apiGetCourseStudyProcess = (courseId) => {
  return request.get("/course/getCourseStudyProcess?courseId=" + courseId);
};

//获取任务学习记录
export const apiFindUserCatalog = (courseCatalogId,courseId) => {
  return request.get("/course/findUserCatalog?courseCatalogId=" + courseCatalogId+"&courseId="+courseId);
};

//检查上一个任务是否完成
export const apiCheckPreTaskComplete = (courseCatalogId,courseId) => {
  return request.get("/course/checkPreTaskComplete?id=" + courseCatalogId+"&courseId="+courseId);
};

export const apiUserCourseCatalogList = (params) => {
  return request.post("/course/userCourseCatalog/list", params);
};

export const operation = (id, operationType) => {
  return request.get(`/course/operation?id=${id}&operationType=${operationType}`);
};

export const detail = (id) => {
  return request.get(`/course/operation?id=${id}`);
};


export const apiGetStudyProcessList = (params) => {
  return request.post("/course/courseStudyProcessList", params);
};

//我的足迹
export const apiGetMyFootPrint = (params) => {
  return request.post("/course/myFootPrint", params);
};

//我的收藏
export const apiGetMyCollect = (params) => {
  return request.post("/course/myCollect", params);
};

//最近学习的课程任务
export const apiGetLatestStudyTask = (courseId) => {
  return request.get(`/course/latestStudyTask?courseId=${courseId}`);
};

/**
 * 获取任务学习进度
 * @param courseCatalogId
 */
export const apiGetTaskStudyTime = (courseCatalogId,courseId) => {
  return request.get(`/course/getTaskStudyTime?courseCatalogId=${courseCatalogId}&courseId=${courseId}`);
};

//提交评论
export const apiCommitComment = (params) => {
  return request.post("/course/comment", params);
};

/**
 * 评论列表
 * @param params
 */
export const apiGetCommentList = (params) => {
  return request.post("/course/commentList", params);
};

/**
 * 查询所有子评论
 * @param params
 */
export const apiListChildComment = (params) => {
  return request.post("/course/listChildComment", params);
};

export const listGoodsEvaluation = (params) => {
  return request.post(`/course/goodsEvaluation`, params);
};

export const countGradeNumber = (goodsId) => {
  return request.get("/course/countGradeNumber?goodsId=" + goodsId);
};


/**
 * 首页进行中和即将开始的课程
 * @param params
 */
export const apiStartCourseList = (params) => {
  return request.post(`/course/timeSelectList`, params);
};